<?php
include("include/config.inc.php");

if(isset($_POST['incomingId']))
{
	$selectProcess = "SELECT processId1, processId2, processId3, temp1, soaking1, furnace1, temp2, soaking2, furnace2, temp3, soaking3, furnace3
	                    FROM incoming
	                   WHERE incomingId = ".$_POST['incomingId'];
  $selectProcessRes = mysql_query($selectProcess);
  $processArray = array();
  $a = 0;
  if($processRow = mysql_fetch_array($selectProcessRes))
  {
  	$processArray[$a]['processId1'] = $processRow['processId1'];
  	$processArray[$a]['processId2'] = $processRow['processId2'];
  	$processArray[$a]['processId3'] = $processRow['processId3'];
  	
  	$processArray[$a]['process1'] = 0;
  	$processArray[$a]['process2'] = 0;
  	$processArray[$a]['process3'] = 0;
  	
  	if($processRow['temp1'] != 0)
  	{
  	  $processArray[$a]['temp1']    = $processRow['temp1'];
  	  $processArray[$a]['soaking1'] = $processRow['soaking1'];
  	  $processArray[$a]['furnace1'] = $processRow['furnace1'];
  	  $processArray[$a]['process1'] = 1;
  	}
  	if($processRow['temp2'] != 0)
  	{
  	  $processArray[$a]['temp2']    = $processRow['temp2'];
  	  $processArray[$a]['soaking2'] = $processRow['soaking2'];
  	  $processArray[$a]['furnace2'] = $processRow['furnace2'];
  	  $processArray[$a]['process2'] = 1;
  	}
  	if($processRow['temp3'] != 0)
  	{
    	$processArray[$a]['temp3']    = $processRow['temp3'];
    	$processArray[$a]['soaking3'] = $processRow['soaking3'];
  	  $processArray[$a]['furnace3'] = $processRow['furnace3'];
  	  $processArray[$a]['process3'] = 1;
  	}
  	$a++;
  }
echo Json_Encode($processArray);  
}
?>